package com.etc.entity;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class SkillFactory {

	public static Skill createSkill(String skillType, String skillId, String skillName,
			String skillDesc,int skillCd, int consumBlue, String type, int attrHeal, 
			int attrImage, int attrAttack, int attrCrit, int attrDefense, int attrSpeed, 
			int duration, String classId ) {
		
		//设置参数
		Class[] paramTypes =new Class[] {String.class, String.class, String.class, int.class, int.class, String.class,
				int.class, int.class, int.class, int.class, int.class, int.class, int.class, String.class };
		Object[] params = new Object[] {skillId, skillName, skillDesc, skillCd, consumBlue, type,
				attrHeal, attrImage, attrAttack, attrCrit, attrDefense, attrSpeed, duration, classId};
		Skill skill = null;
		Class clazz = null;
		
		String className = "com.etc.entity." + skillType;
		try {
			clazz = Class.forName(className);
			Constructor<Skill> constructor = clazz.getConstructor(paramTypes);
			skill = constructor.newInstance(params);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			e.printStackTrace();
		} catch (SecurityException e) {
			e.printStackTrace();
		}		
		return skill;
	}
	
	public static void main(String[] args) {
		
		
	}
}
